#include <stdio.h>
#include <string.h>
typedef struct {
	int id;//工号 
	char name[50];//姓名 
	char sex;//性别
	char birthday[10];//出生日期
	char native_place[10];//籍贯
	int age;//年龄
	char rank[10];//职称

	float base_salary;//基本工资 
	float bouns;//奖金 
	float deduction;//扣款 
	float net_salary;//实际工资 
}Employee;
Employee employees[20];
void delete(Employee employees[], int *n)
void add(Employee employees[]);
void deletegh(Employee employees[], int *n);
void deletename(Employee employees[], int *n);

void delete(Employee employees[],  *n)
{	int a;
	printf("    选择删除操作\n");
	printf("    1->按工号删除\n");
	printf("    2->按姓名删除\n");
	scanf(" %d",&a) ;
	switch(a);
	{	case 1:{deletegh(Employee employees[],  *n);
				break;
	  			}
		case 2:{deletename(Employee employees[],  *n);
				break;
		}
		default:
            printf("无效的操作\n");
	}
	
 } 

void add(Employee employees[])
{	int i,n;
	printf("请输入添加职工的个数：");
	scanf("%d",&n) ;
	for(i=0;i<n;i++)
	{scanf("%d", &employees->id);  // 添加工号
    scanf("%s", employees->name); // 添加姓名
    scanf(" %c", &employees->sex); // 添加性别
    scanf("%s", employees->birthday); // 添加出生日期
    scanf("%s", employees->native_place); // 添加籍贯
    scanf("%d", &employees->age); // 添加年龄
    scanf("%s", employees->rank);//添加职称 
    scanf("%f", &employees->base_salary); // 添加基本工资
    scanf("%f", &employees->bouns); // 添加奖金
    scanf("%f", &employees->deduction); // 添加扣款
    scanf("%f", &employees->net_salary); // 添加实际工资 
	}
    
}



void deletegh(Employee employees[], int *n)
{
    int i, j, id1;
    printf("请输入要删除职工的工号：");
    scanf("%d", &id1);

    for (i = 0; i < *n; i++)
    {
        if (employees[i].id ==id1)
        {
            for (j = i + 1; j < *n; j++)
            {
                employees[j - 1] = employees[j];
            }
            (*n)--;
            break;
        }
    }
}

void deletename(Employee employees[], int *n)
{
    int i, j, flag = 0;
    char name[20];
    printf("请输入要删除职工的名字：");
    scanf("%s", name);

    for (i = 0; i < *n; i++)
    {
        if (strcmp(employees[i].name, name) == 0)
        {
            for (j = i + 1; j < *n; j++)
            {
                employees[j - 1] = employees[j];
            }
            (*n)--;
            flag = 1;
            break;
        }
    }

    if (flag)
        printf("删除成功！\n");
    else
        printf("未找到该名字的职工。\n");
}